/*
 * Observable.cpp
 *
 *  Created on: 25 févr. 2012
 *      Author: jed
 */


#include "Observable.h"


Observable* Observable::instance = NULL;

Observable* Observable::GetInstance()
{
	if ( instance == NULL ) {
		instance = new Observable();
	}

	return instance;
}

void Observable::addEventListener(Observer& o)
{
	observers.insert(&o);
}

void Observable::removeEventListener(Observer& o)
{
	observers.erase(&o);
}

void Observable::NotifyObservers()
{
	set<Observer*>::iterator itr;
	for ( itr = observers.begin();
			itr != observers.end(); itr++ )
		(*itr)->Notify();
	// (*itr)->Notify(this);

}

// TEST METHOD TO TRIGGER
void Observable::Trigger()
{
	NotifyObservers();
}


Observable::Observable() {

}

Observable::~Observable() {

}

